<?php
date_default_timezone_set('UTC');
require_once('tcpdf/tcpdf.php');
require_once('dao/compteRenduDao.php');
require_once('tcpdf/examples/lang/eng.php');
require_once('ConnectBD.php');
require_once('dao/tacheDao.php');
require_once('dao/nomadeDao.php');
require_once('dao/compteRenduDao.php');
require_once('dao/interventionDao.php');
require_once('dao/materielCommandeDao.php');
$pdf = new TCPDF('P', PDF_UNIT, 'A4', true, 'UTF-8', false); 
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Producteur');
$pdf->SetTitle("titre");
$pdf->SetSubject('Sujet');
$pdf->SetKeywords('mots clés');
$pdf->SetAutoPageBreak(TRUE, 13);
$pdf->SetPrintHeader(false); 
$pdf->SetPrintFooter(false);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
$pdf->setLanguageArray($l); 
$pdf->AddPage('P');
$pdf->SetFont('times', '', 8);

$htmltable="";
// Le contenu du pdf ou le body
//--------------------------------------------
//*********************************compterendu
//--------------------------------------------
if($page="compteRendu"){
    $compteRenduDao=new compteRenduDao();                    //instancier l objet compteRenduDao
    $compteRendus = $compteRenduDao->loadAllComptesRendus();
    foreach($compteRendus as $line){
			$return[] = array(
						"id"         => $line->getIdCompteRendu(),
						"designation"=> $line->getDesignation(),
						"description"=> $line->getDescription(),
						"dateFin"    => $line->getDateFin()								
						);
	}
    $htmltable.='<h1 align="center">MédiaFast</h1><h1 align="right">'.date("d/m/Y").'</h1>'.'<img src="images/icons/media2.png" width="160px" alt="mediafast"/>';
	$htmltable.='<h1 ><span color="#FF9999" align="center">Liste des Comptes rendus</span></h1>';
	$htmltable.='<table width="100%" border="0.5">
					<tr align="center">
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Id</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Designation</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Description</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Date Fin</b></font></th>
					</tr>';
	
	foreach($return as $line){
		  $htmltable.='<tr align="center"> 
		              <td>'.utf8_encode($line["id"]).'</td>
		              <td>'.utf8_encode($line["designation"]).'</td>
		              <td>'.utf8_encode($line["description"]).'</td>
		              <td>'.utf8_encode($line["dateFin"]).'</td>
		              </tr>';
        
	}
	$htmltable.='</table>';
}

//--------------------------------------------
//********************************INTERVENTION
//--------------------------------------------
if($page="intervention"){
	$htmltable="";
     $interventionDao=new interventionDao();                   //instancier l objet tacheDao
     $interventions = $interventionDao->loadAllIntervention();// importer la liste des donnees
                                                             //ranger les donnees dans une table
    foreach($interventions as $line){
			$returne[] = array(
						"idNomade"         => $line->getIdNomade(),
						"objectif"   => $line->getObjectif(),
						"dessignation"=> $line->getDesignation(),
						"dateDebut"  => $line->getDateDebut(),
						"nomadeCible"=> $line->getIdNomadeCible()								
						);
	}
    $htmltable.='<h1 align="center">MédiaFast</h1><h1 align="right">'.date("d/m/Y").'</h1>'.'<img src="images/icons/media2.png" width="160px" alt="mediafast"/>';
	$htmltable.='<h1 ><span color="#FF9999" align="center">Liste des interventions</span></h1>';
	$htmltable.='<table width="100%" border="0.5">
					<tr align="center">
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Id</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Objectif</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Designation</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Date Debut</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Nomade Cible</b></font></th>
					</tr>';
	
	foreach($returne as $line){
		  $htmltable.='<tr align="center"> 
		              <td>'.utf8_encode($line["idNomade"]).'</td>
		              <td>'.utf8_encode($line["objectif"]).'</td>
		              <td>'.utf8_encode($line["dessignation"]).'</td>
		              <td>'.utf8_encode($line["dateDebut"]).'</td>
		              <td>'.utf8_encode($line["nomadeCible"]).'</td>
		              </tr>';
        
	}
	$htmltable.='</table>';
}
//--------------------------------------------
//***************************MATERIEL COMMANDE
//--------------------------------------------
if($page="materielCommande"){
     /*$materielCommandeDao=new materielCommandeDao();                       //instancier l objet tacheDao
       $materielCommandes = $materielCommandeDao->loadAllMaterielCommande();// importer la liste des donnees
                                          //ranger les donnees dans une table
    __".$materielCommande->."__".$materielCommande->."<br>"; 
  
    foreach($materielCommandes as $line){
			$materiel[] = array(
						"reference"   => $line->getReference(),
						"constructeur"=> $line->getConstructeur(),
						"connecteur"  => $line->getConnecteur(),
						"type"        => $line->getType(),
						"quantite"    => $line->getQuantite(),	
						"dateCmd"    => $line->getDateCommande(),
						"nomade"      => $line->getIdNomadeCible()								
						);
	}
    $htmltable.='<h1 align="center">MédiaFast</h1><h1 align="right">'.date("d/m/Y").'</h1>'.'<img src="images/icons/media2.png" width="160px" alt="mediafast"/>';
	$htmltable.='<h1 ><span color="#FF9999" align="center">Liste des interventions</span></h1>';
	$htmltable.='<table width="100%" border="0.5">
					<tr align="center">
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Reference</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Constructeur</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Connecteur</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Type</b></font></th>
						<th STYLE="background-color: red;color:white;"><font size="10"><b>Quantite</b></font></th>
					    <th STYLE="background-color: red;color:white;"><font size="10"><b>Date Commande</b></font></th>
					    <th STYLE="background-color: red;color:white;"><font size="10"><b>Nomade</b></font></th>
					</tr>';






	
	foreach($return as $line){
		  $htmltable.='<tr align="center"> 
		              <td>'.utf8_encode($line["id"]).'</td>
		              <td>'.utf8_encode($line["objectif"]).'</td>
		              <td>'.utf8_encode($line["designation"]).'</td>
		              <td>'.utf8_encode($line["dateDebut"]).'</td>
		              <td>'.utf8_encode($line["nomadeCible"]).'</td>
		              </tr>';
        
	}
	$htmltable.='</table>';*/
}














$pdf->writeHTML($htmltable, true, 0, true, 0);
ob_clean();  
$pdf->Output('designation.pdf', 'I');